project(geotr)
cmake_minimum_required(VERSION 2.6)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake-modules)
set(TARNAME geotr)

################################################################################################################################
if(NOT DEFINED LIB_INSTALL_DIR)
	set(LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib")
endif(NOT DEFINED LIB_INSTALL_DIR)
if(NOT DEFINED INCLUDE_INSTALL_DIR)
	set(INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/include/")
endif(NOT DEFINED INCLUDE_INSTALL_DIR)
if(NOT DEFINED BIN_INSTALL_DIR)
	set(BIN_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/sbin")
endif(NOT DEFINED BIN_INSTALL_DIR)
################################################################################################################################

################################################################################################################################

add_definitions(-Wall -Wextra)

#include_directories(
	#${LIBICONV_INCLUDE_DIRS}
	#${CMAKE_CURRENT_SOURCE_DIR}
	#${CMAKE_CURRENT_BINARY_DIR}
	#)

set(geotr_SRC
	traceroute.c
	ifaddrlist.c
	findsaddr-socket.c
	version.c
	as.c
	libmanip/manip.c
)

set(INPERM
	SETUID OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
)
################################################################################################################################

add_executable(geotr ${geotr_SRC})
target_link_libraries(geotr ${LIBICONV_LIBRARIES})
SET_TARGET_PROPERTIES(geotr 
	PROPERTIES COMPILE_FLAGS "-O2 -mdynamic-no-pic -dead_strip -DHAVE_SOCKADDR_SA_LEN"
	LINK_FLAGS "-liconv"
	OUTPUT_NAME "geotr"
)

install(TARGETS geotr 
	RUNTIME DESTINATION ${BIN_INSTALL_DIR} 	PERMISSIONS ${INPERM}
)


add_executable(geotrace ${geotr_SRC})
target_link_libraries(geotrace ${LIBICONV_LIBRARIES})
SET_TARGET_PROPERTIES(geotrace
	PROPERTIES COMPILE_FLAGS "-O2 -mdynamic-no-pic -dead_strip -DHAVE_SOCKADDR_SA_LEN -arch i386 -arch x86_64 -arch ppc"
	LINK_FLAGS "-liconv -arch i386 -arch x86_64 -arch ppc"
	OUTPUT_NAME "geotrace"
)
install(TARGETS geotrace
	RUNTIME DESTINATION ${BIN_INSTALL_DIR} PERMISSIONS ${INPERM}
)
################################################################################################################################

